<!--?xml version="1.0" encoding="UTF-8"?--><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <title>Git学习五：多人协作开发</title>
 </head>
 <body style="zoom: 1.08741;">
  <div>
   1：什么是git的分支？
  </div>
  <div>
   <br />
  </div>
  <div>
   &nbsp; &nbsp; git的分支管理是类似一个快照的类型，每个分支是一个快照。不同分支之间是平行管理的。git分支本质是指向提交对象的指针，每次提交都是指针移动的过程。
  </div>
  <div>
   <br />
  </div>
  <div>
   2：分支的创建
  </div>
  <div>
   &nbsp;&nbsp; &nbsp;
  </div>
  <div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902);-en-codeblock:true;">
   <div>
    <span style="font-size: 12px; color: rgb(51, 51, 51); font-family: Monaco;">#创建分支</span>
   </div>
   <div>
    git branch -b xxx
   </div>
   <div>
    <br />
   </div>
   <div>
    #查看分支
   </div>
   <div>
    <font face="Monaco">git branch</font>
   </div>
  </div>
  <div>
   Git分支的创建时，是在你当前所在的分支通过head头直接进行扩展的，
  </div>
  <div>
   <br />
  </div>
  <div>
   3：提交log日志查看
  </div>
  <div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902);-en-codeblock:true;">
   <div>
    <font face="Monaco">git log --oneline&nbsp;—decorate</font>
   </div>
   <div>
    <font face="Monaco">git log&nbsp;</font>
   </div>
   <div>
    <font face="Monaco">git log&nbsp;—-oneline</font>
   </div>
   <div>
    <font face="Monaco">git log -decorate</font>
   </div>
   <div>
    <font face="Monaco">Git log&nbsp;—graph</font>
   </div>
  </div>
  <div>
   <br />
  </div>
  <div>
   <img src="html/Git5.resources/5C2EDAD5-0994-49E0-834B-8840687147B0.jpg" height="530" width="732" />
   <br />
  </div>
  <div>
   <br />
  </div>
  <div>
   4：分支切换
  </div>
  <div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902);-en-codeblock:true;">
   <div>
    git checkout branch_name
   </div>
  </div>
  <div>
   切换分支需要注意的是每个分支都是独自的开发场景，当A分支切换到B分支时A分支修改的东西并不会带到B分支中。值得注意的是如果你的A分支没有处理干净的话是不能进行分支切换的。
  </div>
  <div>
   <br />
  </div>
  <div>
   5：分支间的数据合并
  </div>
  <div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902);-en-codeblock:true;">
   <div>
    <font face="Monaco">#merge的分支名是要和当前所在分支进行合并</font>
   </div>
   <div>
    <font face="Monaco">git merge merger_branch_name</font>
   </div>
  </div>
  <div>
   <br />
  </div>
  <div>
   6：分支删除
  </div>
  <div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902);-en-codeblock:true;">
   <div>
    git branch -d delect_branch_name
   </div>
  </div>
  <div>
   <br />
  </div>
  <div>
   7：分支冲突解决
  </div>
  <div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902);-en-codeblock:true;">
   <div>
    <span style="font-family: Monaco; font-size: 12px; color: rgb(51, 51, 51);">Git用&lt;&lt;&lt;&lt;&lt;&lt;&lt;，=======，&gt;&gt;&gt;&gt;&gt;&gt;&gt;标记出不同分支的内容</span>
   </div>
  </div>
  <div>
   <br />
  </div>
  <div>
   8：分支合并
  </div>
  <div>
   &nbsp; &nbsp;&nbsp;Fast forward 快速合并模式：这种模式下删除分支会丢失分支信息
  </div>
  <div>
   &nbsp; &nbsp; 普通模式 ：—no—ff方式，会在合并时新生成一个commit，可以在分支上看到历史信息
  </div>
  <div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902);-en-codeblock:true;">
   <div>
    <span style="font-family: Monaco; font-size: 12px; color: rgb(51, 51, 51);">git merge --no-ff -m &quot;merge with no-ff&quot; dev</span>
   </div>
  </div>
  <div>
   9：远程同步
  </div>
  <div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902);-en-codeblock:true;">
   <div>
    <span style="font-family: Monaco; font-size: 12px; color: rgb(51, 51, 51);">git fetch origin</span>
   </div>
  </div>
  <div>
   <br />
  </div>
 </body>
</html>